#include<iostream>
using namespace std;
#include<vector>

void perm(vector<char> v,vector<char> curp);

void pv(const vector<char>& v);

int main(){
    //待全排列数组
    vector<char> v;
    v.push_back('a');
    v.push_back('b');
    v.push_back('c');
    v.push_back('d');
    //临时存储全排列的数组
    vector<char> curp;
    curp.clear();
    //全排列函数
    perm(v,curp);
    return 0;
}

void perm(vector<char> v,vector<char> curp)
{
    if(v.size() <= 0){
        //打印curp内的信息
        pv(curp);
        return;
    }
    for(int i=0; i<v.size(); i++){
        curp.push_back(v[i]);
        auto rv = v;
        rv.erase(rv.begin()+i);
        perm(rv,curp);
        curp.pop_back();
    }
}

void pv(const vector<char>& v)
{
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << " ";
    }
    cout << endl;
}